package com.jcli.file;

import java.io.File;
import java.io.IOException;

public class FileDemo {
    public static void main(String[] args) throws IOException {
        File file = new File("src/abc.txt");
        File file1 = new File("abc.txt");
        File file3 = new File("d:/abc.txt");
        if (!file1.exists()) {
            file1.createNewFile();
        }
        //文件夹的创建
        File file5 = new File("aaa.txt");
        if (!file5.exists()) {
            file5.mkdir();
        }
        File file6 = new File("src/main/resources/abc/bca/ddd");
        if (!file6.exists()) {
            file6.mkdirs();
        }
        File file7 = new File(file6,"txt.bat");
        if (!file7.exists()){
            file7.createNewFile();
        }
        file5.delete();
        file6.delete();
        System.out.println(file7.isFile());
        System.out.println(file6.isDirectory());

        File file8 = new File("../kkk.txt");
        if (!file8.exists()){
            file8.createNewFile();
        }

        System.out.println(file8.getAbsolutePath());
        System.out.println(file8.getCanonicalPath());
        System.out.println(file8.getName());
        System.out.println(file8.getParent());
        System.out.println(file8.getPath());
        System.out.println(file8.length());
    }
}
